package com.example.chain.component.planB;

import java.util.ArrayList;
import java.util.List;

/**
 * @author shixiaodong
 * @date 2022-06-01
 */
public abstract class AbstractDecision {

    List<DecisionService> chain = new ArrayList<>();

    int index = 0;

    public void doNext() {
        if (index < chain.size()) {
            DecisionService service = chain.get(index);
            index++;
            service.makeDecision(this);
        }
    }

    public void addChain(DecisionService service) {
        chain.add(service);
    }

}
